package aex.service;



import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import aex.dao.ArticleCategoryDao;
import aex.domain.ArticleCategory;
import aex.util.PageBean;



@Transactional(readOnly = false)
@Service(ArticleCategoryService.SERVICE_NAME)

public class ArticleCategoryService  {

	
	public static final String SERVICE_NAME="aex.service.ArticleCategoryService";
	/**
	 * 以注解的形式让spring为我们注入dao的实现类
	 */
	@Resource(name = ArticleCategoryDao.SERVICE_NAME)
	public ArticleCategoryDao dao;
	
	public ArticleCategoryService() {
		
	}
	public ArticleCategory findByID(Serializable id) {
		return dao.findObjectByID(Integer.parseInt(id+""));
	}
	public void deleteById(Serializable id) {
		dao.deleteObjectByIDs(Integer.parseInt(id+""));
	}
	public void save(ArticleCategory obj) {
		dao.save(obj);
	}
	public void update(ArticleCategory obj) {
		dao.merge(obj);
	}
	public PageBean<ArticleCategory> findAll(PageBean<ArticleCategory> pageBean) {
		LinkedHashMap<String, String> orderby=new LinkedHashMap<String, String>();
		orderby.put("tName.acOrderBy", "asc");
		return dao.findPageBean(" ", null, orderby, pageBean);
	}
	public int findCategoryCount() {
		LinkedHashMap<String, String> orderby=new LinkedHashMap<String, String>();
		orderby.put("tName.acOrderBy", "asc");
		return dao.findCollectionByConditionNoPage(" ", null, orderby).size();
	}
	public List<ArticleCategory> findAllNoPage() {
		LinkedHashMap<String, String> orderby=new LinkedHashMap<String, String>();
		orderby.put("tName.acOrderBy", "asc");
		return dao.findCollectionByConditionNoPage("and tName.acName <>'官方小组' ", null, orderby);
	}
	
	/**
	 * 带官方小组
	 * @return
	 */
	public List<ArticleCategory> findAllNoPage2() {
		LinkedHashMap<String, String> orderby=new LinkedHashMap<String, String>();
		orderby.put("tName.acOrderBy", "asc");
		return dao.findCollectionByConditionNoPage(" ", null, orderby);
	}
}
